<template>
	<view>
		<empty v-if="total === 0"></empty>
		<view class="ml-36 pr-36 ptb-25 flex bb" v-for="(item,i) in list" :key="i">
			<view class="u-flex-1 mr-20">
				<view class="bold">
					{{item.memo}}
				</view>
				<view class="size-26 gray-2 mt-10">
					{{item.createtime_text}}
				</view>
			</view>
			<view :class="[item.score>=0?'green':'red','size-26']">
				{{item.score>=0?'+':''}}{{item.score}}
			</view>
		</view>
		<u-loadmore v-show="list.length && list.length <= total" :status="status" icon-type="flower" bg-color="transperant" margin-top="30" margin-bottom="30" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isActive:1,
				page:1,
				status: 'loadmore',
				list:[],
				total: null
			}
		},
		onPullDownRefresh() {
			this.page = 1
			this.list = []
			this.getList()
		},
		onReachBottom() {
			if (this.status == 'loading' || this.status == 'nomore') {
				return;
			}
			this.getList()
		},
		onLoad(option) {
			uni.setNavigationBarTitle({
				title: '积分明细'
			})
			this.getList()
		},
		methods: {
			getList(){
				this.status = "loading";
				this.$http('/api/user/scorelog', {
					page: this.page
				}).then(data => {
					this.list = this.list.concat(data.rows);
					this.total = data.total;
					if (this.list.length >= data.total) {
						this.status = "nomore";
					} else {
						this.page = this.page + 1
						this.status = "loadmore";
					}
					uni.stopPullDownRefresh();
				});
			}
		}
	}
</script>

<style>

</style>
